<?php
/*
 * 进云智能生成平台
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
 */
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$_SESSION['homeurl']='';
$return=array();
$account =pdo_get('core_accounts',array('uniacid'=>$_SESSION['uniacid']));
if($_RQ['op']=='main'){
	$fields=array('id','title','keyword','createtime','readnum','likenum','status','desc','pic_url','yingxiao','content');
	$orderby=array();
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['num']){
		$psize = $_RQ['num'];
	}else{
		$psize = 10;
	}
	$total='';
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if($account['newsgroupid']){
		$params['fenlei']=$account['newsgroupid'];
		$return['newsgroupid']=$account['newsgroupid'];
	}
	$news=pdo_getslice('core_account_article',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($news){
		foreach($news as &$item){
			$item['content'] = strip_tags(str_replace('&nbsp;','',$item['content']));
			$item['desc'] = $item['desc'] ? $item['desc'] : cfc('tools')->substr($item['content'],0,36);
			$item['picurl'] = $item['pic_url'] ? $item['pic_url'] : '../core/resource/images/nopic.jpg';
			$item['createtime']=date('y/m/d H:i:s',$item['createtime']);
			$item['url']=custom_url('core/article.list/detail/id='.$item['id'],true);
		}
	}
	//推荐商品
	$parameter=array(
		'params'=>array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'saletype likes'=>array('1')),
		'fields'=>array('id','title','image','price','total','active_plugin','active_id','salenum','pluginname'),
		'limit'=>10,
	);
	$goods=model('jy_weishop/goods')->goods_list($parameter);
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1);
	if($_RQ['keyword']){
		$params['title like']='%'.trim($_RQ['keyword']).'%';
	}
	if($_RQ['groupid']){
		$params['groupid']=intval($_RQ['groupid']);
		$return['params']['groupid']=intval($_RQ['groupid']);
	}
    $orderby='id desc';
	$total='';
	$videos=pdo_getslice('jy_weishop_video',$params,array($pindex,$psize),$total,'','',$orderby);
	foreach($videos as &$itemv){
		$itemv['images']=json_decode($itemv['images'],true);
		$pindex = max(1, 0);
		$members=pdo_getslice('jy_weishop_video_looklist',array('uniacid'=>$_SESSION['uniacid'],'oid'=>$itemv['id']),array($pindex,5),$total,array('mid'),'','id desc');
		foreach($members as &$mv){
			$memberinfo=pdo_get('core_members',array('id'=>$mv['mid']),array('nickname','avatar'));
			$mv['nickname']=$memberinfo['nickname'];
			$mv['avatar']=$memberinfo['avatar'];
		}
		$itemv['members']=$members;
		$itemv['likes']=pdo_count('jy_weishop_video_like',array('uniacid'=>$_SESSION['uniacid'],'oid'=>$itemv['id']),'id');
	}
	$return['news']=$return['list']=$news;
	$return['goods']=$goods;
	$return['videos']=$videos;
	$account['hdps']=json_decode($account['hdps'],true);
	$account['apps']=json_decode($account['apps'],true);
	$account['plugins']=json_decode($account['plugins'],true);
	$account['h5game']=json_decode($account['h5game'],true);
	$account['navs']=json_decode($account['navs'],true);
	$account['mobilenavs']=json_decode($account['mobilenavs'],true);
	$account['links']=json_decode($account['links'],true);
	$account['cip']=json_decode($account['cip'],true);
	$plugin_name=pdo_getcolumn('core_account_group',array('id'=>$account['groupid']),'plugin_name');
	$account['pluginurl']=$plugin_name?custom_url($plugin_name.'/index/',true):'jy_weishop';
	$return['account']=$account;
	$return['domain']=DOMAIN_PRE;
	$return['sharedata']=array(
		'title'=>$account['title'],
		'desc'=>$account['desc'],
		'link'=>custom_url('home.welcome/',true),
		'imgUrl'=>ATTACHMENT_URL.$account['logo'],
	);
	set_html('title',$_SESSION['account']['title']);
	$return['extradata']=array();
	exi($return);
}
